package com.zzw.service.impl;

import com.zzw.dao.ConsumerDao;
import com.zzw.pojo.Consumer;
import com.zzw.service.ConsumerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class ConsumerServiceImpl implements ConsumerService {
    @Autowired
    private ConsumerDao consumerDao;
    @Override
    public PageInfo findPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Consumer> list = consumerDao.findByPage(pageNum,pageSize);
        PageInfo<Consumer> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void addConsumer(Consumer consumer) {
        consumerDao.addConsumer(consumer);
    }

    @Override
    public List<Consumer> findAll() {
        return consumerDao.findAll();
    }
}
